package tcc.resources;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Read a file
 * @author Gabriel Pacheco
 *
 */
public class ReadFile {
	private final String dirOrigem = ".";
	private final String fileOrigem = "goals.csv";
	
	public List<Integer> readInteger() {
		List<Integer> ids = new ArrayList<Integer>(); //list of IDs
		
		File fileRead = new File(this.dirOrigem,this.fileOrigem); 
		FileReader rf = null;
		BufferedReader br = null;
		
		String line;

		try {
			rf = new FileReader(fileRead);
			br = new BufferedReader(rf);
			
			try {
				while((line = br.readLine())!= null) {
					ids.add(Integer.parseInt(line));
				}
			}catch (Exception e) {
				System.out.println("Erro aqui");
			}
		}catch (Exception e) {
			System.out.println("File not Found!");
			e.printStackTrace();
		}finally {
			try {
				br.close();
			} catch (IOException e) {
				
			}
		}
		
		return ids;
	}

	
	public List<String> readString() {
		List<String> descricao = new ArrayList<String>(); //list of IDs
		
		File fileRead = new File(this.dirOrigem,this.fileOrigem); 
		FileReader rf = null;
		BufferedReader br = null;
		
		String line;

		try {
			rf = new FileReader(fileRead);
			br = new BufferedReader(rf);
			
			try {
				while((line = br.readLine())!= null) {
					descricao.add(line);
				}
			}catch (Exception e) {
				System.out.println("Erro aqui");
			}
		}catch (Exception e) {
			System.out.println("File not Found!");
			e.printStackTrace();
		}finally {
			try {
				br.close();
			} catch (IOException e) {
				
			}
		}
		
		return descricao;
	}
}
